package validator;


public class EnterpriseValidator {	
	
	private Integer id;
	private String name;
	private String fullname;
	
	public EnterpriseValidator(String id, String name, String fullname){
		try{
			this.id = Integer.parseInt(id);
		} catch(NullPointerException | NumberFormatException e){
			this.id = null;			
		}
		if(name != null && !name.isEmpty()) this.name = name;
		if(fullname != null && !fullname.isEmpty()) this.fullname = fullname;		
	}

	public Integer getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getFullname() {
		return fullname;
	}
	
	public boolean isValid(){
		return id != null && name != null && fullname != null;
	}
	
	public String getErrorMessage(){
		StringBuilder strb = new StringBuilder();
		if(id == null) strb.append("ID fault\n");
		if(name == null) strb.append("name fault\n");
		if(fullname == null) strb.append("fullname fault");		
		return strb.toString();				
	}
	
}
